package online.szlib.com.core.services;

import java.util.List;

import online.szlib.com.core.domain.Catalog;
import online.szlib.com.core.repositories.CatalogRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("catalogService")
public class CatalogServiceImpl implements CatalogService{

	@Autowired
	private CatalogRepository catalogRepository;
	
	public List<Catalog> listBookCatalogs(){
		return catalogRepository.findAll();
	}
	
	public Catalog getBookCatalog(Long bookRecNo){
		return catalogRepository.findOne(bookRecNo);
	}
	
	public Long create(Catalog bookCatalog){
		catalogRepository.save(bookCatalog);
		return bookCatalog.getBookRecNo();
	}
	
	public void update(Catalog bookCatalog){
		catalogRepository.saveAndFlush(bookCatalog);
	}
	
	public void deleteById(Long id){
		catalogRepository.delete(id);
	}
}
